package Operation;

import Bill.BillList;
import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Scanner;

public class Income extends MySql implements IOperation{
    @Override
    public void work() throws SQLException {
        Scanner scanner = new Scanner(System.in);

        System.out.println("请输入日期");
        System.out.println("格式****-**-**");
        String time = scanner.nextLine();

        System.out.println("请输入金额");
        int money = scanner.nextInt();

        String In_Or_Ex = null;
        do{
            System.out.println("请输入收入/支出");
            scanner.nextLine();
            In_Or_Ex = scanner.nextLine();
            if(In_Or_Ex.equals("支出")){
                money = money * (-1);
            }
            if(In_Or_Ex.equals("收入") || In_Or_Ex.equals("支出")){
                break;
            }
        }while(true);

        System.out.println("请输入备注");
        String remark = scanner.nextLine();

       super.Add(time,money,In_Or_Ex,remark);
        System.out.println("添加成功");
        System.out.println("===============================");
    }
}
